import { Controller, Post, Body } from '@nestjs/common';
import adminConfig from '@src/config/admin.config';
import { LoginService } from '@src/services/admin/login/login.service';
import { ApiTags, ApiOperation, ApiCreatedResponse } from '@nestjs/swagger';
import { LoginDto } from './dto/login.dto';

@ApiTags('用户登录')
@Controller(`${adminConfig.adminPath}/login`)
export class LoginController {
  constructor (
    private readonly loginService: LoginService
  ) { }


  @ApiOperation({
    summary: '用户登录',
    description: '用户名和密码登录',
  })
  @ApiCreatedResponse({
    type: LoginDto,
    description: '用户登录DTO'
  })
  @Post()
  async adminLogin(
    @Body() loginDto: LoginDto,
  ): Promise<any> {
    return this.loginService.adminLogin(loginDto);
  }
}
